<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script>
</head>

<body>
  <div id='app'>
    <h2>{{message}}</h2>
    <my-cpn></my-cpn>
  </div>
  <div id="app1">
    <my-cpn></my-cpn>
  </div>
  <script>
    // 1.创建组件构造器
    const myComponent = Vue.extend({
      template: `
        <div id='app'>
    <h2>组件标题</h2>
  </div>`
    })

    // // 2.注册组件
    // const Feature = Vue.component('my-cpn', myComponent);
    // 3.使用组件
    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello world'
      }
    })

    const app1 = new Vue({
      el: '#app1',
      data: {

      },
      components: {
        'myCpn': myComponent
      }
    })
  </script>
</body>

</html>